﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TransCend.DB
{
    public class OrderBy
    {
        public enum Type { ASC, DESC }

        private Type _order = Type.ASC;

        public Type Order
        {
            get { return _order; }
            set { _order = value; }
        }

        public string Sort
        {
            get;
            set;
        }

        public static OrderBy GetOrderBy(string sort, Type order)
        {
            return new OrderBy(sort, order);
        }

        public static OrderBy GetOrderBy(string sort)
        {
            return new OrderBy(sort, Type.ASC);
        }

        public OrderBy(string sort)
        {
            Sort = sort;
        }

        public OrderBy(string sort, Type order)
        {
            Order = order;
            Sort = sort;
        }

        public OrderBy(string sort, string order)
        {
            Order = order.ToUpper() == ORDER_DESC ? Type.DESC : Type.ASC;
            Sort = sort;
        }

        public const string ORDER_DESC = "DESC";
        public const string ORDER_ASC = "ASC";
    }
}
